/*
 * @Author: zi.yang
 * @Date: 2022-11-27 21:55:46
 * @LastEditors: zi.yang
 * @LastEditTime: 2022-12-04 00:16:01
 * @Description:
 * @FilePath: /promise/test/common.js
 */
/* eslint-disable no-console */

exports.log = (...args) => {
  const len =
    args.reduce((prev, cur) => {
      const curStr = cur || String(cur);
      return prev + JSON.stringify(curStr).length;
    }, 0) + 4;
  console.log(`\n${'='.repeat(len)}`);
  console.log('|', ...args, '|');
  console.log('='.repeat(len));
};

exports.timeout = (callback = () => {}, time = 0) => {
  const timer = setTimeout(() => {
    callback();
    clearTimeout(timer);
  }, time);
};
